<?php
/**
 * Created by JetBrains PhpStorm.
 * User: luca
 * Date: 11/06/13
 * Time: 15:23
 * To change this template use File | Settings | File Templates.
 */

// crea tutte le tassonomie che servono
function adleex_training_taxonomy() {

    // placing
/*
    $labels = array(
        'name' => 'Placing',
        'singular_name' => 'Placing',
        'search_items' => 'Search by placing',
        'all_items' => 'All Placing',
        'parent_item' => 'Placing',
        'parent_item_colon' => '',
        'edit_item' => 'Edit placing',
        'update_item' => 'Update placing',
        'add_new_item' => 'Add new placing',
        'new_item_name' => 'New placing',
        'menu_name' => 'Placing'
    );

    $cap = array(
        'manage_terms' => 'manage_options',
        'edit_terms' => 'manage_options',
        'delete_terms' => 'manage_options',
        'assign_terms' => 'edit_posts',  //@TODO verifica la giusta capability


    );


    adleex_register_taxonomy('adleex_placing', $labels,true,true,$cap);
*/

    // topic
    $labels = array(
        'name' => 'Topic',
        'singular_name' => 'Topic',
        'search_items' => 'Search by topics',
        'all_items' => 'All topics',
        'parent_item' => 'Main Topic',
        'parent_item_colon' => '',
        'edit_item' => 'Edit topic',
        'update_item' => 'Update topic',
        'add_new_item' => 'Add new topic',
        'new_item_name' => 'New topic',
        'menu_name' => 'Topic'
    );
    $cap = array(
        'manage_terms' => 'edit_posts',
        'edit_terms' => 'edit_posts',
        'delete_terms' => 'edit_posts',
        'assign_terms' => 'edit_posts',

    );
    adleex_register_taxonomy('adleex_topic', $labels,false,false,$cap);



    // documentType
    $labels = array(
        'name' => 'Document Types',
        'singular_name' => 'Type',
        'search_items' => 'Search document types',
        'all_items' => 'All document types',
        'parent_item' => '',
        'parent_item_colon' => '',
        'edit_item' => 'Edit document type',
        'update_item' => 'Update document type',
        'add_new_item' => 'Add new document type',
        'new_item_name' => 'New document type',
        'menu_name' => 'Types'
    );
    $cap = array(
        'manage_terms' => 'manage_options',
        'edit_terms' => 'manage_options',
        'delete_terms' => 'manage_options',
        'assign_terms' => 'edit_documents',

    );
    adleex_register_taxonomy('adleex_documenttype', $labels,true,true,$cap);

    if (!term_exists( 'lecture', 'adleex_documenttype')) {
        // parte, lezione, approfondimento, integrazione, introduzione, fuori tema, documento esterno
        insert_term('Part', 'adleex_documenttype', array('description'=> 'Risorsa umana con ruolo di docente'));
        insert_term('Lecture', 'adleex_documenttype', array('description'=> 'Fornitore di servizi'));
        insert_term('Update', 'adleex_documenttype', array('description'=> 'Aula in cui svolgere i corsi'));
        insert_term('Wiki', 'adleex_documenttype', array('description'=> 'Risorsa umana con ruolo di segretaria'));
        insert_term('Out topic', 'adleex_documenttype', array('description'=> 'Risorsa umana con ruolo di segretaria'));
        insert_term('Document', 'adleex_documenttype', array('description'=> 'Risorsa umana con ruolo di segretaria'));
        insert_term('Introduction', 'adleex_documenttype', array('description'=> 'Risorsa umana con ruolo di segretaria'));
        insert_term('Homework', 'adleex_documenttype', array('description'=> 'Risorsa umana con ruolo di segretaria'));
    }

    // activityType
    $labels = array(
        'name' => 'Activity Types',
        'singular_name' => 'Type',
        'search_items' => 'Search activity types',
        'all_items' => 'All activity types',
        'parent_item' => '',
        'parent_item_colon' => '',
        'edit_item' => 'Edit activity type',
        'update_item' => 'Update activity type',
        'add_new_item' => 'Add new activity type',
        'new_item_name' => 'New activity type',
        'menu_name' => 'Types'
    );
    $cap = array(
        'manage_terms' => 'manage_options',
        'edit_terms' => 'manage_options',
        'delete_terms' => 'manage_options',
        'assign_terms' => 'edit_activities',

    );
    adleex_register_taxonomy('adleex_activitytype', $labels, true, true,$cap);
    if (!term_exists( 'lecture', 'adleex_activitytype')) {
        // laboratorio, questionario, test, stage, sondaggio, simulazione
        insert_term('Test', 'activitytype', array('description'=> 'Risorsa umana con ruolo di docente'));
        insert_term('Stage', 'activitytype', array('description'=> 'Fornitore di servizi'));
        insert_term('Simulation', 'activitytype', array('description'=> 'Aula in cui svolgere i corsi'));
        insert_term('Survey', 'activitytype', array('description'=> 'Risorsa umana con ruolo di segretaria'));
        insert_term('Laboratory', 'activitytype', array('description'=> 'Risorsa umana con ruolo di segretaria'));
        insert_term('Homework', 'activitytype', array('description'=> 'Risorsa umana con ruolo di segretaria'));
        insert_term('Introduction', 'activitytype', array('description'=> 'Risorsa umana con ruolo di segretaria'));
        insert_term('Homework', 'activitytype', array('description'=> 'Risorsa umana con ruolo di segretaria'));
    }

    // resourceType
    $labels = array(
        'name' => 'Resource Types',
        'singular_name' => 'Type',
        'search_items' => 'Search resource types',
        'all_items' => 'All resource types',
        'parent_item' => '',
        'parent_item_colon' => '',
        'edit_item' => 'Edit resource type',
        'update_item' => 'Update resource type',
        'add_new_item' => 'Add new resource type',
        'new_item_name' => 'New resource type',
        'menu_name' => 'Types'
    );
    $cap = array(
        'manage_terms' => 'manage_options',
        'edit_terms' => 'manage_options',
        'delete_terms' => 'manage_options',
        'assign_terms' => 'edit_resources',

    );
    adleex_register_taxonomy('adleex_resourcetype', $labels, true, true,$cap);
    if (!term_exists( 'Teacher', 'adleex_resourcetype')) {
        insert_term('Teacher', 'adleex_resourcetype', array('description'=> 'Risorsa umana con ruolo di docente'));
    }

    // competence
    $labels = array(
        'name' => 'Competences',
        'singular_name' => 'Competence',
        'search_items' => 'Search competence',
        'all_items' => 'All competence',
        'parent_item' => '',
        'parent_item_colon' => '',
        'edit_item' => 'Edit competence',
        'update_item' => 'Update competence',
        'add_new_item' => 'Add new competence',
        'new_item_name' => 'New competence',
        'menu_name' => 'Competences'
    );
    $cap = array(
        'manage_terms' => 'manage_options',
        'edit_terms' => 'manage_options',
        'delete_terms' => 'manage_options',
        'assign_terms' => 'edit_resources',

    );
    adleex_register_taxonomy('adleex_competence', $labels, false, false,$cap);


    // classification (of course)
    $labels = array(
        'name' => 'Classification',
        'singular_name' => 'Classification',
        'search_items' => 'Search course classification',
        'all_items' => 'All classification',
        'parent_item' => '',
        'parent_item_colon' => '',
        'edit_item' => 'Edit course classification',
        'update_item' => 'Update course classification',
        'add_new_item' => 'Add new classification',
        'new_item_name' => 'New classification',
        'menu_name' => 'Classifications'
    );
    $cap = array(
        'manage_terms' => 'manage_options',
        'edit_terms' => 'manage_options',
        'delete_terms' => 'manage_options',
        'assign_terms' => 'edit_courses',

    );
    adleex_register_taxonomy('adleex_classification', $labels, false, false,$cap);


    // partner
    $labels = array(
        'name' => 'Partners',
        'singular_name' => 'Partner',
        'search_items' => 'Search partners',
        'all_items' => 'All partners',
        'parent_item' => '',
        'parent_item_colon' => '',
        'edit_item' => 'Edit partner',
        'update_item' => 'Update partner',
        'add_new_item' => 'Add new partner',
        'new_item_name' => 'New partner',
        'menu_name' => 'Partners'
    );
    $cap = array(
        'manage_terms' => 'edit_courses',
        'edit_terms' => 'edit_courses',
        'delete_terms' => 'edit_courses',
        'assign_terms' => 'edit_courses',

    );
    $fields = array(
        'name' => array(),
        'address' => array()
    );
    adleex_register_taxonomy('adleex_partner', $labels, false, true,$cap);


    // enrollRole
    $labels = array(
        'name' => 'Roles for course',
        'singular_name' => 'Role',
        'search_items' => 'Search roles for course',
        'all_items' => 'All roles for course',
        'parent_item' => '',
        'parent_item_colon' => '',
        'edit_item' => 'Edit role',
        'update_item' => 'Update role',
        'add_new_item' => 'Add new role for course',
        'new_item_name' => 'New role for course',
        'menu_name' => 'Roles'
    );
    $cap = array(
        'manage_terms' => 'manage_options',
        'edit_terms' => 'manage_options',
        'delete_terms' => 'manage_options',
        'assign_terms' => 'edit_enrolls',

    );
    adleex_register_taxonomy('adleex_role', $labels, false, false,$cap);
    if (!term_exists( 'teacher', 'adleex_role')) {
        insert_term('Teacher', 'adleex_role', array('description'=> 'Risorsa umana con ruolo di docente'));
        insert_term('Student', 'adleex_role', array('description'=> 'Fornitore di servizi'));
        insert_term('Tutor', 'adleex_role', array('description'=> 'Aula in cui svolgere i corsi'));
        insert_term('Secretary', 'adleex_role', array('description'=> 'Risorsa umana con ruolo di segretaria'));
        insert_term('Classroom', 'adleex_role', array('description'=> 'Risorsa umana con ruolo di segretaria'));
        insert_term('Services', 'adleex_role', array('description'=> 'Risorsa umana con ruolo di segretaria'));
        insert_term('---', 'adleex_role', array('description'=> 'Risorsa umana con ruolo di segretaria'));
        insert_term('+++', 'adleex_role', array('description'=> 'Risorsa umana con ruolo di segretaria'));
    }

    // threadType
    $labels = array(
        'name' => 'Thread Types',
        'singular_name' => 'Type',
        'search_items' => 'Search thread types',
        'all_items' => 'All thread types',
        'parent_item' => '',
        'parent_item_colon' => '',
        'edit_item' => 'Edit thread type',
        'update_item' => 'Update thread type',
        'add_new_item' => 'Add new thread type',
        'new_item_name' => 'New thread type',
        'menu_name' => 'Types'
    );
    $cap = array(
        'manage_terms' => 'manage_options',
        'edit_terms' => 'manage_options',
        'delete_terms' => 'manage_options',
        'assign_terms' => 'edit_threads',

    );
    adleex_register_taxonomy('adleex_threadtype', $labels, true, true,$cap);
    if (!term_exists( 'Question', 'adleex_threadtype')) {
        insert_term('Question', 'adleex_threadtype', array('description'=> 'Generale question from student to all'));
        insert_term('Forum', 'adleex_threadtype', array('description'=> 'Generale question from student to all'));
        insert_term('Ticket', 'adleex_threadtype', array('description'=> 'Generale question from student to all'));
        insert_term('Chat', 'adleex_threadtype', array('description'=> 'Generale question from student to all'));
    }


}


add_action('init', 					'adleex_training_taxonomy');
